<?php

namespace app\api\controller\v1;

use app\common\controller\Api;
use think\Request;

class ClassTeam extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function getClassTeamInfo(Request $request)
    {
        // 假设这里有一个ClassTeam模型
        $data = [
            [
                'title' => "一级学院",
                'children' => [
                    [
                        'title' => "二级学院",
                        'children' => [
                            ['title' => "2024班级1"],
                            ['title' => "2024班级2"]
                        ]
                    ],
                    [
                        'title' => "二级学院",
                        'children' => [
                            ['title' => "2024班级1"],
                            ['title' => "2024班级2"]
                        ]
                    ]
                ]
            ],
            [
                'title' => "一级学院",
                'children' => [
                    [
                        'title' => "二级学院",
                        'children' => [
                            ['title' => "2024班级1"],
                            ['title' => "2024班级2"]
                        ]
                    ],
                    [
                        'title' => "二级学院",
                        'children' => [
                            ['title' => "2024班级1"],
                            ['title' => "2024班级2"]
                        ]
                    ]
                ]
            ],
            [
                'title' => "一级学院",
                'children' => [
                    [
                        'title' => "二级学院",
                        'children' => [
                            ['title' => "2024班级1"],
                            ['title' => "2024班级2"]
                        ]
                    ],
                    [
                        'title' => "二级学院",
                        'children' => [
                            ['title' => "2024班级1"],
                            ['title' => "2024班级2"]
                        ]
                    ]
                ]
            ]
        ];

        $this->success('获取成功', $data);
    }

    public function applyJoinClass(Request $request)
    {
        $data = $request->post();
        $className = $data['class_name'];
        // 假设这里有一个Class模型
        $class = \app\admin\model\Classes::where('name', $className)->find();
        if ($class) {
            // 这里可以添加申请加入的逻辑
            // 例如：记录申请记录、发送通知等
            $this->success('申请成功');
        } else {
            $this->error('班级不存在');
        }
    }
}
